home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / nwtp.faq < prev    next >
Text File  |  1996-07-10  |  7KB  |  199 lines

  1. FAQ for the NWTP API
  2. ====================
  3.  
  4. B01. How am I knwon at the server ?
  5. B02. How do I give someone Console Operator rights ?
  6.  
  7. C01. How can I reset the servertime ?
  8. C02. How can I synchronize the workstation's time to that of the server ?
  9.  
  10. L01. How can I place a limit on the number of concurrent users of my
  11.      program ? (licensing)
  12.  
  13. M01. How can I send a message to another user ?
  14.  
  15. S01. How do I determine whether or not I'm logged into a server ?
  16. S02. Is the shell installed ?
  17. S03. What is the name of the server I'm logged into ?
  18.  
  19. ******************************** Answers ********************************
  20.  
  21. B01. What name do I have ?
  22. --------------------------
  23. A: You are known at the server by two names: a short (object) name
  24.    (i.e. the name you use to login) and a full name stored in the
  25.    bindery.
  26.  
  27.    Var SecurityLevel:Byte;
  28.        ObjectID:Longint;
  29.        ObjectType:Word;
  30.        ObjectName,LongName:String;
  31.    begin
  32.    GetBinderyAccessLevel(SecurityLevel,ObjectID);
  33.    GetBinderyObjectname(ObjectID,ObjectName,ObjectType);
  34.    writeln('You''re known to the server as:',ObjectName);
  35.    GetRealUserName(ObjectName,LongName);
  36.    writeln('And to the supervisor as:',LongName);
  37.    if LongName=''
  38.     then writeln('<Your full name wasn''t set by the Supervisor>');
  39.    end.
  40.  
  41. B02. How do I give someone Console Operator rights?
  42. ---------------------------------------------------
  43. A: You'll have to add the ObjectID of the target user to the OPERATORS
  44.    property of the supervisor object in the bindery. Note that having
  45.    console operator rights differs significantly from being supervisor
  46.    equivalent. Console operator rights allow the user to perform actions
  47.    from a workstation that could also be done on the server console.
  48.  
  49.    Var UserName:string;
  50.    begin
  51.    UserName='Goofy';
  52.    IF NOT CreateProperty('SUPERVISOR',OT_USER,'OPERATORS',
  53.              BF_SET or BF_STAT_OBJ,
  54.              BS_LOGGED_READ or BS_SUPER_WRITE)
  55.     then if nwBindry.result<>$ED { property already exists }
  56.       then begin
  57.            writeln('Error creating operators property.');
  58.            Halt(1);
  59.            end;
  60.  
  61.    IF AddBinderyObjectToSet('SUPERVISOR',OT_USER,'OPERATORS',
  62.                 UserName,OT_USER)
  63.     then writeln('User ',UserName,' is now a console operator.');
  64.    end.
  65.  
  66.  
  67. C01. How can I reset the servertime ?
  68. -------------------------------------
  69. A: Use the SetFileServerDateAndTime function in the nwServ unit. In order
  70.    for this call to be successful, you have to either be the supervisor
  71.    or have console operator privileges.
  72.  
  73.    Var newTime:TnovTime;
  74.    begin
  75.    WITH newTime
  76.     do begin
  77.        year:=94; month:=6; day:=1;
  78.        hour:=5;  min:=0;   sec:=0;
  79.        end;
  80.    IF NOT SetFileServerDateAndTime(newTime)
  81.     then writeln('You need to have console operator rights.');
  82.    end.
  83.  
  84. C02. How can I synchronize the workstation's time to that of the server ?
  85. -------------------------------------------------------------------------
  86. A: Use Pascal's SetTime and SetDate functions in combination with the
  87.    GetFileServerDateAndTime function.
  88.  
  89.     Var time:TnovTime;
  90.     year:word;
  91.     begin
  92.     GetFileServerDateAndTime(time);
  93.     if time.year<80
  94.      then year:=2000+time.year
  95.      else year:=1900+time.year;
  96.     setdate(year,time.month,time.day);
  97.     settime(time.hour,time.minute,time.second,0);
  98.     end.
  99.  
  100. L01. How can I place a limit on the number of concurrent users of my program ?
  101. ------------------------------------------------------------------------------
  102. A: Use the semaphore functions in the nwSema unit. Note that these enable
  103.    you to limit the number of concurrent users on a server basis. When a
  104.    user is refused access because the limit for his current fileserver is
  105.    exceeded, he can simply login to another fileserver (if available) and
  106.    try to use the program there. Limiting the number of concurrent users
  107.    on multiple servers in an internetwork is quite a problem: Novell doesn't
  108.    provide a method to synchronize semaphore values between servers.
  109.  
  110.  
  111.      CONST
  112.       INITIAL_SEMAPHORE_VALUE=10;
  113.        { suppose a licence for 10 concurrent users }
  114.       SEMAPHORE_NAME='YourProgramName';
  115.        { anything goes, as long as it's unique. Max. 128 characters.}
  116.  
  117.      VAR openCount :Word;
  118.      semValue  :Integer;
  119.      semHandle :LongInt;
  120.  
  121.      BEGIN {main}
  122.  
  123.      { Open Semaphore }
  124.      semValue := INITIAL_SEMAPHORE_VALUE;
  125.          { Need in case we're creating the semaphore }
  126.      IF NOT OpenSemaphore( SEMAPHORE_NAME, semValue, semHandle, openCount )
  127.       then begin
  128.        writeln('Error opening semaphore. error #',nwSema.Result);
  129.        Halt(1);
  130.        end;
  131.      { Wait on the Semaphore (get permission to use the program) }
  132.      IF NOT WaitOnSemaphore( semHandle, 0 )
  133.       then begin
  134.        if ( nwSema.Result = $FE )
  135.         then begin
  136.          writeln( 'Sorry, license exceeded. Please try again later.' );
  137.          halt(1);
  138.          end
  139.         else begin
  140.          writeln('WaitOnSemaphore returned eror# ',nwSema.result);
  141.          halt(1);
  142.          end;
  143.        end;
  144.  
  145.      { <=====  INSERT YOUR to be licensed PROGRAM HERE =====> }
  146.  
  147.      { Signal Semaphore (that we're through with the program) }
  148.      SignalSemaphore( semHandle );
  149.      { Close Semaphore }
  150.      CloseSemaphore( semHandle );
  151.      end.
  152.  
  153.  
  154.  
  155. M01. How can I send a message to another user ?
  156. -----------------------------------------------
  157. A: Use the SendMessageToUser function in the nwMess unit. This
  158.    function allows you to send a message to a user or to the members
  159.    of a group. If there are more than 64 members in the group, only the
  160.    first 64 members of the group will receive the message due to the way
  161.    this function is implemented on the server.
  162.  
  163.    var name    : string;
  164.        message : string;
  165.    begin
  166.    name    := 'MBRAMWEL';
  167.    message := 'Hi Mark, how is it going?';
  168.    SendMessageToUser(name,message);
  169.    SendMessageToUser('FINANCE_DEPT','Hand over the money..');
  170.    SendMessageToUser('*','Goodmorning');
  171.    end.
  172.  
  173.    Note that unlike the messages broadcasted by the SEND utility, the
  174.    source of the message is not automatically put in the message itself.
  175.  
  176. S01. How do I determine whether or not I'm logged into a server ?
  177. -----------------------------------------------------------------
  178. A: Use the nwBindr IsUserLoggedOn function.
  179.  
  180.  
  181. S02. Is the shell installed ?
  182. ----------------------------------------------
  183. A: Use the nwBindy IsShellLoaded function or query the variables
  184.    NETX_EXE_Loaded or VLM_EXE_Loaded. (see nwIntr)
  185.  
  186.  
  187. S03. What is the name of the server I'm logged into ?
  188. -----------------------------------------------------
  189. A: If you already know that you're logged in:
  190.  
  191.    Var ConnId:Byte;
  192.        ServerName:string;
  193.    begin
  194.    GetEffectiveConnectionID(ConnId);
  195.    IF GetFileserverName(connId,ServerName)
  196.     then Writeln('You''re logged into server :',ServerName);
  197.    end.
  198.  
  199.